//
//  ViewController.swift
//  CHCrypto
//
//  Created by cyptt on 2024/5/20.
//

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        self.cbcSM4Example()
    }

    func cbcSM4Example() {
        let secretKey = "scca@123scca@123"
        let iv = "scca@123scca@123"
        // 密钥（需要是Data类型）
        let secretKeyData = "scca@123scca@123".data(using: .utf8)!
        // 初始化向量（需要是Data类型）
        let ivData = "scca@123scca@123".data(using: .utf8)!
          
        // 明文
        let oriStr = "测试"
        let msgData = oriStr.data(using: .utf8)!
        print("明文: \(oriStr)")
          
        // 加密
        let sm4 = CHSM4.cbcSM4(withKey: secretKey, iv: iv)
        
     
        let encryptionString = sm4?.encryption(oriStr)
        print(encryptionString)
    }
      
}

